package com.xuecheng.content.controller;

import com.xuecheng.content.mapper.CourseTeacherMapper;
import com.xuecheng.content.model.po.CourseTeacher;
import com.xuecheng.content.service.CourseTeacherService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * @author: Hes
 * @description 师资接口
 * @date: 2023/6/20 22:05
 */
@RestController
@Api(value = "师资接口", tags = "师资接口")
public class CourseTeacherController {
    @Autowired
    CourseTeacherService courseTeacherService;

    /**
     * 师资信息查询接口
     *
     * @param courseId
     * @return
     */
    @ApiOperation("师资信息查询接口")
    @GetMapping("/courseTeacher/list/{courseId}")
    public List<CourseTeacher> list(@PathVariable("courseId") Long courseId) {
        List<CourseTeacher> list = courseTeacherService.list(courseId);
        System.out.println(list);
        return list;
    }

    /**
     * 增加师资信息接口
     *
     * @param courseTeacher
     * @return
     */
    @ApiOperation("增加师资信息接口")
    @PostMapping("/courseTeacher")
    public CourseTeacher courseTeacher(@RequestBody CourseTeacher courseTeacher) {
        Long companyId = 1232141425L;
        CourseTeacher courseTeacherFormDB = courseTeacherService.courseTeacher(companyId, courseTeacher);
        return courseTeacherFormDB;
    }

    /**
     * 修改师资信息接口
     *
     * @param courseTeacher
     * @return
     */
    @ApiOperation("修改师资信息接口")
    @PutMapping("/courseTeacher")
    public CourseTeacher ModifyCourseTeacher(@RequestBody CourseTeacher courseTeacher) {
        Long companyId = 1232141425L;
        CourseTeacher courseTeacherFromDB = courseTeacherService.modifyCourseTeacher(companyId, courseTeacher);
        return courseTeacherFromDB;

    }
    @ApiOperation("删除师资信息接口")
    @DeleteMapping("/courseTeacher/course/{courseId}/{teacherId}")
    public void delTeacher(@PathVariable("courseId") Long courseId,@PathVariable("teacherId") Long teacherId){
        courseTeacherService.delTeacher(courseId,teacherId);
    }

}
